home *** CD-ROM | disk | FTP | other *** search
- class Bird extends SideScroller.StaticObject
- {
- var bObjectBlock;
- var bObjectSpecial;
- var nBaseY;
- var mcRef;
- var nSinGenerator;
- var bDoEntrySound;
- static var nMIN_X = 150;
- static var nMOVE_SPEED = 3;
- static var nSIN_INCREMENT = 0.15;
- static var nSIN_MOD_MULT = 15;
- static var nPROB_ENTRY_SOUND = 65;
- static var nENTRY_SOUND_PLAYER_DIST = 350;
- function Bird(__mcRef, __oLayer)
- {
- super(__mcRef,__oLayer);
- this.bObjectBlock = false;
- this.bObjectSpecial = true;
- this.nBaseY = this.mcRef._y;
- this.nSinGenerator = 0;
- LevelManager.Instance.doPutInFront(this.mcRef);
- this.setState("Idle");
- if(Library.Utils.MoreMath.getRandomRange(1,100) < Bird.nPROB_ENTRY_SOUND)
- {
- this.bDoEntrySound = true;
- }
- else
- {
- this.bDoEntrySound = false;
- }
- this.ParentLayer.doAddListener(this);
- }
- function doPause()
- {
- super.doPause();
- for(var _loc3_ in this.mcRef.mcState)
- {
- this.mcRef.mcState[_loc3_].stop();
- }
- }
- function onHitSpecial(__oRef)
- {
- if(this.CurrentState == "Idle")
- {
- if(!TakGround(__oRef).IsInHeadSwing)
- {
- TakGround(__oRef).doReactCollision();
- }
- else
- {
- Library.Sound.SoundManager.doPlaySoundInCat(Main.SOUND_CAT_SOUND,"ItemHit.mp3",100,1,true);
- }
- var _loc2_ = this.ParentLayer.doAttachVisual("Tak_MiniM01");
- _loc2_._x = this.Coord.x;
- _loc2_._y = this.Coord.y;
- LevelManager.Instance.doAddMiniStone(_loc2_);
- Library.Sound.SoundManager.doPlaySoundInCat(Main.SOUND_CAT_SOUND,"BirdColision.mp3",100,1,true);
- this.setState("Die");
- this.doLockState();
- }
- }
- function doDestroy()
- {
- this.ParentLayer.doRemoveListener(this);
- super.doDestroy();
- }
- function doIdle()
- {
- if(this.bDoEntrySound)
- {
- if(Math.abs(TakGround.Instance.Coord.x - this.Coord.x) < Bird.nENTRY_SOUND_PLAYER_DIST)
- {
- this.bDoEntrySound = false;
- var _loc2_ = Library.Utils.MoreMath.getRandomRange(1,100);
- if(_loc2_ < 33)
- {
- Library.Sound.SoundManager.doPlaySoundInCat(Main.SOUND_CAT_SOUND,"BirdEntry-01.mp3",100,1,true);
- }
- else if(_loc2_ < 66)
- {
- Library.Sound.SoundManager.doPlaySoundInCat(Main.SOUND_CAT_SOUND,"BirdEntry-02.mp3",100,1,true);
- }
- else
- {
- Library.Sound.SoundManager.doPlaySoundInCat(Main.SOUND_CAT_SOUND,"BirdEntry.mp3",100,1,true);
- }
- }
- }
- this.nSinGenerator += Bird.nSIN_INCREMENT;
- var _loc3_ = Math.sin(this.nSinGenerator) * Bird.nSIN_MOD_MULT;
- this.mcRef._x -= Bird.nMOVE_SPEED;
- this.mcRef._y = this.nBaseY + _loc3_;
- }
- function doDie()
- {
- if(this.isStateComplete())
- {
- this.ParentLayer.doRemoveListener(this);
- this.doDestroy();
- }
- }
- }
-